You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could either keep it as a wrapper type of rcgen::Issuer or phase it out completely.
If we were gonna phase it out I would do it with the following changes:
Drop rustls_cert_gen::Ca in favor of rcgen::Issuer
Add a conversion from rcgen::Issuer to rcgen::CertifiedKey using From or to_certified_key method.
Move rcgen::PemCertifiedKey::write to rcgen::CertifiedKey::write_pem (replacing Ca::serialize_pem().write with Issuer::to_certified_key().write_pem(), alternatively we could also just have Issuer::write_pem)
Drop rustls_cert_gen::PemCertifiedKey in favor of rcgen::CertifiedKey (which is fine because the method is now write_pem not write)
Remove rustls_cert_gen::EndEntity::serialize_pem and provide conversion from rustls_cert_gen::EndEntity to rcgen::CertifiedKey using From or to_certified_key method.
Should rustls_cert_gen::EndEntity just be rcgen::CertifiedKey or is that too far?
KeyPair and Clone?
I have removed the lifetime from Issuer so it holds owned values, as I personally think this is the best call and it was implied by @djc's message linked above.
This does raise an interesting concern, how should CertificateParams::self_signed construct an rcgen::Issuer as it takes in &KeyPair and we would require an owned KeyPair.
Options:
Implement Clone publically for KeyPair and make CertificateParams::self_signed take KeyPair
Implement Clone privately for KeyPair and use it
Make Issuer hold a Cow<'a, KeyPair> and provide an Issuer::to_owned method which allocates the data and returns Issuer<'static>.
Make Issuer hold a lifetime to the KeyPair
Option 4 has the major downside that it makes parsing around an Issuer really difficult due to it always having a lifetime to some buffer. I know in my personal use of rcgen I load the issuer on startup and give it around to Tokio tasks, and it would be nice to avoid leaking memory as would be required with this option.
rcgen::Issuer vs rcgen::CertifiedKey?
Aren't these basically the same type.
rustls_cert_gen::Ca being either a wrapper or replaced by rcgen::Issuer means we need to provide a way to go from an Issuer to Certificate which we will use to replace/reimplement the existing rustls_cert_gen::Ca::cert method.
Given this, I think it seems logical that in code Issuer could be:
We could either keep it as a wrapper type of rcgen::Issuer or phase it out completely.
If we were gonna phase it out I would do it with the following changes:
* [ ] Drop `rustls_cert_gen::Ca` in favor of `rcgen::Issuer`
* [ ] Add a conversion from `rcgen::Issuer` to `rcgen::CertifiedKey` using `From` or `to_certified_key` method.
* [ ] Move `rcgen::PemCertifiedKey::write` to `rcgen::CertifiedKey::write_pem` (replacing `Ca::serialize_pem().write` with `Issuer::to_certified_key().write_pem()`, alternatively we could also just have `Issuer::write_pem`)
* [ ] Drop `rustls_cert_gen::PemCertifiedKey` in favor of `rcgen::CertifiedKey` (which is fine because the method is now `write_pem` not `write`)
* [ ] Remove `rustls_cert_gen::EndEntity::serialize_pem` and provide conversion from `rustls_cert_gen::EndEntity` to `rcgen::CertifiedKey` using `From` or `to_certified_key` method.
* [ ] Should `rustls_cert_gen::EndEntity` just be `rcgen::CertifiedKey` or is that too far?
I generally think we should focus on getting the rcgen API first before we think much about the rustls-cert-gen API -- in the end for rustls-cert-gen, it's really only the CLI that matters. That said, it probably makes sense to replace Ca with Issuer.
KeyPair and Clone?
I have removed the lifetime from Issuer so it holds owned values, as I personally think this is the best call and it was implied by @djc's message linked above.
This does raise an interesting concern, how should CertificateParams::self_signed construct an rcgen::Issuer as it takes in &KeyPair and we would require an owned KeyPair.
Options:
* [ ] Implement `Clone` publically for `KeyPair` and make `CertificateParams::self_signed` take `KeyPair`
* [ ] Implement `Clone` privately for `KeyPair` and use it
* [ ] Make `Issuer` hold a `Cow<'a, KeyPair>` and provide an `Issuer::to_owned` method which allocates the data and returns `Issuer<'static>`.
* [ ] Make `Issuer` hold a lifetime to the `KeyPair`
I think we should start to have a type system-level difference between the notion of self-signed certificates in general and CA-level certificates (which have some extra metadata). As such, I think perhaps CertificateParams::self_signed() is the exception and it should not take an Issuer, instead only taking the &KeyPair it takes today.
TODO
The from_ca_cert_*() constructors from CertificateParams move to Issuer, and we see if we can address the documented caveats on those methods.
Gotta do this as @djc noted in the linked message.
Moving the from_ca_cert_*() constructors is important. I also think we'll want to stop storing the params in Certificate and take &self as a reference in signed_by() methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation #274, based off #269 (comment)
Still required before merge:
Questions
rustls_cert_gen::Ca?We could either keep it as a wrapper type of
rcgen::Issueror phase it out completely.If we were gonna phase it out I would do it with the following changes:
rustls_cert_gen::Cain favor ofrcgen::Issuerrcgen::Issuertorcgen::CertifiedKeyusingFromorto_certified_keymethod.rcgen::PemCertifiedKey::writetorcgen::CertifiedKey::write_pem(replacingCa::serialize_pem().writewithIssuer::to_certified_key().write_pem(), alternatively we could also just haveIssuer::write_pem)rustls_cert_gen::PemCertifiedKeyin favor ofrcgen::CertifiedKey(which is fine because the method is nowwrite_pemnotwrite)rustls_cert_gen::EndEntity::serialize_pemand provide conversion fromrustls_cert_gen::EndEntitytorcgen::CertifiedKeyusingFromorto_certified_keymethod.rustls_cert_gen::EndEntityjust bercgen::CertifiedKeyor is that too far?KeyPairandClone?I have removed the lifetime from
Issuerso it holds owned values, as I personally think this is the best call and it was implied by @djc's message linked above.This does raise an interesting concern, how should
CertificateParams::self_signedconstruct anrcgen::Issueras it takes in&KeyPairand we would require an ownedKeyPair.Options:
Clonepublically forKeyPairand makeCertificateParams::self_signedtakeKeyPairCloneprivately forKeyPairand use itIssuerhold aCow<'a, KeyPair>and provide anIssuer::to_ownedmethod which allocates the data and returnsIssuer<'static>.Issuerhold a lifetime to theKeyPairOption 4 has the major downside that it makes parsing around an
Issuerreally difficult due to it always having a lifetime to some buffer. I know in my personal use ofrcgenI load the issuer on startup and give it around to Tokio tasks, and it would be nice to avoid leaking memory as would be required with this option.rcgen::Issuervsrcgen::CertifiedKey?Aren't these basically the same type.
rustls_cert_gen::Cabeing either a wrapper or replaced byrcgen::Issuermeans we need to provide a way to go from anIssuertoCertificatewhich we will use to replace/reimplement the existingrustls_cert_gen::Ca::certmethod.Given this, I think it seems logical that in code
Issuercould be:which is
rcgen::CertifiedKey.I could be missing something but if they are the same type I feel like unifying them into one makes sense and simplifies the public API.
TODO
Gotta do this as @djc noted in the linked message.